package com.example.uniquekey;

import org.springframework.stereotype.Component;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

/**
 * @author shishaopeng
 * Date: 2023-10-09-00-34
 * Desc:
 */
@Component
public class DataSourceConnectionFactory implements ConnectionFactory {

    private DataSource dataSource = null;

    public DataSourceConnectionFactory(DataSource dataSource) {
        this.dataSource = dataSource;
    }

    @Override
    public Connection createConnection() throws SQLException {
        return dataSource.getConnection();
    }
}
